package com.rong.DAO;

import com.rong.hibernate.BaseHibernateDAO;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Transaction;
import org.hibernate.criterion.Example;
import com.rong.ORM.ZynUserRight;
/**
 * A data access object (DAO) providing persistence and search support for
 * ZynUserRight entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.rong.DAO.ZynUserRight
 * @author MyEclipse Persistence Tools
 */

public class ZynUserRightDAO extends BaseHibernateDAO {
	private static final Log log = LogFactory.getLog(ZynUserRightDAO.class);
	// property constants
	public static final String USER_ID = "userId";
	public static final String MENU_ID = "menuId";
	public static final String SAVE_OP = "saveOp";
	public static final String DEL_OP = "delOp";
	public static final String UPDATE_OP = "updateOp";
	public static final String QUERY_OP = "queryOp";
	public static final String FU_HE_OP = "fuHeOp";
	public static final String CANCEL_FU_HE_OP = "cancelFuHeOp";
	public static final String HE_XIAO_OP = "heXiaoOp";
	public static final String CANCEL_HE_XIAO_OP = "cancelHeXiaoOp";
	public static final String HE_XIAO_ABNOR_OP = "heXiaoAbnorOp";
	public static final String QIAN_PI_OP = "qianPiOp";
	public static final String CANCEL_QIAN_PI_OP = "cancelQianPiOp";
	public static final String EXTATTR1 = "extattr1";
	public static final String EXTATTR2 = "extattr2";
	public static final String EXTATTR3 = "extattr3";
	public static final String EXTATTR4 = "extattr4";
	public static final String EXTATTR5 = "extattr5";

	public void save(ZynUserRight transientInstance) {
		log.debug("saving ZynUserRight instance");
		try {
			Transaction ts = null;
            ts = getSession().beginTransaction();
			getSession().save(transientInstance);
			ts.commit();
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(ZynUserRight persistentInstance) {
		log.debug("deleting ZynUserRight instance");
		try {
			Transaction ts = null;
            ts = getSession().beginTransaction();
			getSession().delete(persistentInstance);
			ts.commit();
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public ZynUserRight findById(java.lang.Integer id) {
		log.debug("getting ZynUserRight instance with id: " + id);
		try {
			ZynUserRight instance = (ZynUserRight) getSession().get(
					ZynUserRight.class, id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(ZynUserRight instance) {
		log.debug("finding ZynUserRight instance by example");
		try {
			List results = getSession().createCriteria(
					"com.rong.DAO.ZynUserRight").add(Example.create(instance))
					.list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding ZynUserRight instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from ZynUserRight as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByUserId(Object userId) {
		return findByProperty(USER_ID, userId);
	}

	public List findByMenuId(Object menuId) {
		return findByProperty(MENU_ID, menuId);
	}

	public List findBySaveOp(Object saveOp) {
		return findByProperty(SAVE_OP, saveOp);
	}

	public List findByDelOp(Object delOp) {
		return findByProperty(DEL_OP, delOp);
	}

	public List findByUpdateOp(Object updateOp) {
		return findByProperty(UPDATE_OP, updateOp);
	}

	public List findByQueryOp(Object queryOp) {
		return findByProperty(QUERY_OP, queryOp);
	}

	public List findByFuHeOp(Object fuHeOp) {
		return findByProperty(FU_HE_OP, fuHeOp);
	}

	public List findByCancelFuHeOp(Object cancelFuHeOp) {
		return findByProperty(CANCEL_FU_HE_OP, cancelFuHeOp);
	}

	public List findByHeXiaoOp(Object heXiaoOp) {
		return findByProperty(HE_XIAO_OP, heXiaoOp);
	}

	public List findByCancelHeXiaoOp(Object cancelHeXiaoOp) {
		return findByProperty(CANCEL_HE_XIAO_OP, cancelHeXiaoOp);
	}

	public List findByHeXiaoAbnorOp(Object heXiaoAbnorOp) {
		return findByProperty(HE_XIAO_ABNOR_OP, heXiaoAbnorOp);
	}

	public List findByQianPiOp(Object qianPiOp) {
		return findByProperty(QIAN_PI_OP, qianPiOp);
	}

	public List findByCancelQianPiOp(Object cancelQianPiOp) {
		return findByProperty(CANCEL_QIAN_PI_OP, cancelQianPiOp);
	}

	public List findByExtattr1(Object extattr1) {
		return findByProperty(EXTATTR1, extattr1);
	}

	public List findByExtattr2(Object extattr2) {
		return findByProperty(EXTATTR2, extattr2);
	}

	public List findByExtattr3(Object extattr3) {
		return findByProperty(EXTATTR3, extattr3);
	}

	public List findByExtattr4(Object extattr4) {
		return findByProperty(EXTATTR4, extattr4);
	}

	public List findByExtattr5(Object extattr5) {
		return findByProperty(EXTATTR5, extattr5);
	}

	public List findAll() {
		log.debug("finding all ZynUserRight instances");
		try {
			String queryString = "from ZynUserRight";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public ZynUserRight merge(ZynUserRight detachedInstance) {
		log.debug("merging ZynUserRight instance");
		try {
			Transaction ts=null;
			ts=getSession().beginTransaction();
			ZynUserRight result = (ZynUserRight) getSession().merge(
					detachedInstance);
			ts.commit();
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(ZynUserRight instance) {
		log.debug("attaching dirty ZynUserRight instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(ZynUserRight instance) {
		log.debug("attaching clean ZynUserRight instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}